package com.stormragetech.arthas.serialize.convertor;

import lombok.extern.log4j.Log4j2;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;

/**
 * description: parameter type object, type handle
 *
 * @author: Xue Bin
 * @version: 1.0.0-SNAPSHOT
 */
@Log4j2
public class ConvertorType {

    private ConvertorType() {
    }

    static final int PRIMITIVE = 1;
    static final int ARRAY = 2;
    static final int LOCAL = 3;
    static final int ILLEGAL = 4;

    static final Class<?>[] PRIMITIVE_TYPE = {
            String.class,
            boolean.class,
            byte.class,
            short.class,
            int.class,
            long.class,
            float.class,
            double.class,
            char.class,
            Boolean.class,
            Byte.class,
            Short.class,
            Integer.class,
            Long.class,
            Float.class,
            Double.class,
            Character.class,
            BigInteger.class,
            BigDecimal.class
    };

    static final Class<?>[] ARRAY_TYPE = {
            String[].class,
            boolean[].class,
            byte[].class,
            short[].class,
            int[].class,
            long[].class,
            float[].class,
            double[].class,
            char[].class,
            Boolean[].class,
            Byte[].class,
            Short[].class,
            Integer[].class,
            Long[].class,
            Float[].class,
            Double[].class,
            Character[].class,
            BigInteger[].class,
            BigDecimal[].class
    };

    private static final Map<Class<?>, Object> PRIMITIVE_DEFAULTS = new HashMap<Class<?>, Object>() {
        private static final long serialVersionUID = 5753182096254727686L;

        {
            put(boolean.class, false);
            put(byte.class, (byte) 0);
            put(short.class, (short) 0);
            put(char.class, (char) 0);
            put(int.class, 0);
            put(long.class, 0L);
            put(float.class, 0.0f);
            put(double.class, 0.0);
        }
    };
}
